<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>pyramid</title>
    <style>
        body{
            font-family: cursive;
        }
    </style>
</head>
<body>


<script>
    var num = prompt("请输入您想要几层的金字塔：");
    for(var i = 0;i < num; i++){
        var nbsp = num - i -1;
        for(var p = 0;p < nbsp; p++){
            document.write("&nbsp");
        }
        var x = (i+1)*2-1;
        for(var y = 0;y < x; y++){
            document.write("*");
        }
        document.write("<br>");
    }
</script>
</body>
</html>